// $ANTLR 3.4 /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g 2012-04-17 01:05:13

  package t4tools.lepath.query.antlr;
  import t4tools.lepath.query.eval.PathExpression;
  import t4tools.lepath.query.eval.Step;
  import t4tools.lepath.query.eval.SimpleStep;
  import t4tools.lepath.query.eval.Predicate;
  import t4tools.lepath.query.eval.Variable;
  import t4tools.lepath.query.eval.VariableImpl;
  import t4tools.lepath.query.eval.IndexPredicate;


import org.antlr.runtime.*;
import java.util.Stack;
import java.util.List;
import java.util.ArrayList;

@SuppressWarnings({"all", "warnings", "unchecked"})
public class LePathParser extends Parser {
    public static final String[] tokenNames = new String[] {
        "<invalid>", "<EOR>", "<DOWN>", "<UP>", "Digit", "Integer", "JavaIdentifier", "JavaIdentifierPart", "JavaIdentifierStart", "Whitespace", "'$'", "'/'", "'['", "']'"
    };

    public static final int EOF=-1;
    public static final int T__10=10;
    public static final int T__11=11;
    public static final int T__12=12;
    public static final int T__13=13;
    public static final int Digit=4;
    public static final int Integer=5;
    public static final int JavaIdentifier=6;
    public static final int JavaIdentifierPart=7;
    public static final int JavaIdentifierStart=8;
    public static final int Whitespace=9;

    // delegates
    public Parser[] getDelegates() {
        return new Parser[] {};
    }

    // delegators


    public LePathParser(TokenStream input) {
        this(input, new RecognizerSharedState());
    }
    public LePathParser(TokenStream input, RecognizerSharedState state) {
        super(input, state);
    }

    public String[] getTokenNames() { return LePathParser.tokenNames; }
    public String getGrammarFileName() { return "/home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g"; }



    // $ANTLR start "evaluate"
    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:22:1: evaluate returns [PathExpression pe] :s1= step ( '/' s2= step )* ;
    public final PathExpression evaluate() throws RecognitionException {
        PathExpression pe = null;


        Step s1 =null;

        Step s2 =null;


        try {
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:22:36: (s1= step ( '/' s2= step )* )
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:23:3: s1= step ( '/' s2= step )*
            {
            pe = new PathExpression();

            pushFollow(FOLLOW_step_in_evaluate49);
            s1=step();

            state._fsp--;


            pe.addStep(s1);

            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:24:29: ( '/' s2= step )*
            loop1:
            do {
                int alt1=2;
                int LA1_0 = input.LA(1);

                if ( (LA1_0==11) ) {
                    alt1=1;
                }


                switch (alt1) {
            	case 1 :
            	    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:24:30: '/' s2= step
            	    {
            	    match(input,11,FOLLOW_11_in_evaluate54); 

            	    pushFollow(FOLLOW_step_in_evaluate58);
            	    s2=step();

            	    state._fsp--;


            	    pe.addStep(s2);

            	    }
            	    break;

            	default :
            	    break loop1;
                }
            } while (true);


            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return pe;
    }
    // $ANTLR end "evaluate"



    // $ANTLR start "step"
    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:27:1: step returns [Step step] : ident= JavaIdentifier (p= predicate )? ;
    public final Step step() throws RecognitionException {
        Step step = null;


        Token ident=null;
        Predicate p =null;


        try {
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:27:24: (ident= JavaIdentifier (p= predicate )? )
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:28:3: ident= JavaIdentifier (p= predicate )?
            {
            ident=(Token)match(input,JavaIdentifier,FOLLOW_JavaIdentifier_in_step77); 

            step = new SimpleStep(ident.getText());

            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:28:68: (p= predicate )?
            int alt2=2;
            int LA2_0 = input.LA(1);

            if ( (LA2_0==12) ) {
                alt2=1;
            }
            switch (alt2) {
                case 1 :
                    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:28:68: p= predicate
                    {
                    pushFollow(FOLLOW_predicate_in_step83);
                    p=predicate();

                    state._fsp--;


                    }
                    break;

            }


            step.addPredicate(p);

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return step;
    }
    // $ANTLR end "step"



    // $ANTLR start "predicate"
    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:31:1: predicate returns [Predicate p] : '[' (v= var |i= Integer ) ']' ;
    public final Predicate predicate() throws RecognitionException {
        Predicate p = null;


        Token i=null;
        Variable v =null;


        try {
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:31:31: ( '[' (v= var |i= Integer ) ']' )
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:32:3: '[' (v= var |i= Integer ) ']'
            {
            match(input,12,FOLLOW_12_in_predicate99); 

            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:32:7: (v= var |i= Integer )
            int alt3=2;
            int LA3_0 = input.LA(1);

            if ( (LA3_0==10) ) {
                alt3=1;
            }
            else if ( (LA3_0==Integer) ) {
                alt3=2;
            }
            else {
                NoViableAltException nvae =
                    new NoViableAltException("", 3, 0, input);

                throw nvae;

            }
            switch (alt3) {
                case 1 :
                    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:33:9: v= var
                    {
                    pushFollow(FOLLOW_var_in_predicate113);
                    v=var();

                    state._fsp--;


                    p = new IndexPredicate(v);

                    }
                    break;
                case 2 :
                    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:34:9: i= Integer
                    {
                    i=(Token)match(input,Integer,FOLLOW_Integer_in_predicate130); 

                    p = new IndexPredicate(i.getText());

                    }
                    break;

            }


            match(input,13,FOLLOW_13_in_predicate145); 

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return p;
    }
    // $ANTLR end "predicate"



    // $ANTLR start "var"
    // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:39:1: var returns [Variable var] : '$' v= JavaIdentifier ;
    public final Variable var() throws RecognitionException {
        Variable var = null;


        Token v=null;

        try {
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:39:26: ( '$' v= JavaIdentifier )
            // /home/yasko/dev/workspaces/projects/lepath/src/main/java/t4tools/lepath/query/antlr/LePath.g:40:3: '$' v= JavaIdentifier
            {
            match(input,10,FOLLOW_10_in_var158); 

            v=(Token)match(input,JavaIdentifier,FOLLOW_JavaIdentifier_in_var162); 

            var = new VariableImpl(v.getText());

            }

        }
        catch (RecognitionException re) {
            reportError(re);
            recover(input,re);
        }

        finally {
        	// do for sure before leaving
        }
        return var;
    }
    // $ANTLR end "var"

    // Delegated rules


 

    public static final BitSet FOLLOW_step_in_evaluate49 = new BitSet(new long[]{0x0000000000000802L});
    public static final BitSet FOLLOW_11_in_evaluate54 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_step_in_evaluate58 = new BitSet(new long[]{0x0000000000000802L});
    public static final BitSet FOLLOW_JavaIdentifier_in_step77 = new BitSet(new long[]{0x0000000000001002L});
    public static final BitSet FOLLOW_predicate_in_step83 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_12_in_predicate99 = new BitSet(new long[]{0x0000000000000420L});
    public static final BitSet FOLLOW_var_in_predicate113 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_Integer_in_predicate130 = new BitSet(new long[]{0x0000000000002000L});
    public static final BitSet FOLLOW_13_in_predicate145 = new BitSet(new long[]{0x0000000000000002L});
    public static final BitSet FOLLOW_10_in_var158 = new BitSet(new long[]{0x0000000000000040L});
    public static final BitSet FOLLOW_JavaIdentifier_in_var162 = new BitSet(new long[]{0x0000000000000002L});

}